
#!/usr/bin/env bash

source ./env

# k8s-m1 登陆其他机器要免密
apt install sshpass
alias ssh='sshpass ssh -o StrictHostKeyChecking=no'
alias scp='sshpass scp -o StrictHostKeyChecking=no'

# 分发文件
for NODE in "${!MasterArray[@]}"; do
    echo "--- $NODE ${MasterArray[$NODE]} ---"
    scp -r config/$NODE/haproxy/ ${MasterArray[$NODE]}:/etc
    scp -r config/$NODE/keepalived/ ${MasterArray[$NODE]}:/etc
    ssh ${MasterArray[$NODE]} 'systemctl daemon-reload && systemctl enable --now haproxy keepalived && systemctl restart haproxy keepalived'
    echo "---  检测结果如下 ---"
    ssh ${MasterArray[$NODE]} 'ip address && netstat -nltp | grep -E "8443|1080"'
done



